package www.wen.com.common.lib.helper.loading

import android.app.Activity
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.dylanc.loadinghelper.LoadingHelper
import com.gyf.immersionbar.ImmersionBar
import www.wen.com.common.R

/**
 * @author WEN
 * @Description: 可以说首页-发现专用的标题栏
 * @date 2020/12/8 15:27
 */
class FindModuleAdapter(
    private var activity: Context,
    private var isSetTitleBarHeight: Boolean = true, //设置状态栏高度
    internal var action: ((view: View) -> Unit)? = null,
) : LoadingHelper.Adapter<FindModuleAdapter.ViewHolder>(),
        View.OnClickListener {

    override fun onBindViewHolder(holder: ViewHolder) {
        if(isSetTitleBarHeight){
            ImmersionBar.setTitleBar(activity as Activity, holder.placeholderView)
        }
        holder.ivSearch.setOnClickListener(this)
    }

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
        return ViewHolder(inflater.inflate(R.layout.layout_find_module, parent, false))
    }

    class ViewHolder(val view: View) : LoadingHelper.ViewHolder(view) {
        var placeholderView: View = view.findViewById(R.id.placeholderView)
        var ivSearch: View = view.findViewById(R.id.ivRight)
    }

    override fun onClick(v: View) {
        action?.invoke(v)
    }

}